//
//  PublicDefine.swift
//  JianTingSwift
//
//  Created by zhibao on 2024/2/2.
//

import Foundation
func DLog<T>(message: T,
                 file: String = #file,
                 line: Int = #line)
{
    let fileName = (file as NSString).lastPathComponent
    print("\(fileName)第\(line)行：\(message)")
}

let SCREEN_WIDTH = UIScreen.main.bounds.width
let SCREEN_HEIGHT = UIScreen.main.bounds.height
let kMainScreenBounds = UIScreen.main.bounds

//颜色切换定义

let MYRed = MYColor.color(withHexString:"#E04148")
let MYOrange = MYColor.color(withHexString:"#FFD640")
let MYBlue = MYColor.color(withHexString:"#2666e4")
let MYGreen = MYColor.color(withHexString:"#1EA61E")
let ThemeColor = MYColor.color(withHexString:"#0F1011")
let ciThemeColor = MYColor.color(withHexString:"#25282D")
let MYBlock = MYColor.color(withHexString:"#333333")

let HOME = "home"
let NEW = "new"
let OLD = "old"
let PINGBAN = "pingban"
let SHUMA = "shuma"
//定义数据
let shebeiDic = [
    HOME:[
        [
            "name":"Apple iPhone 11 256GB 暗夜绿色 移动联通电信 5G手机 ",
            "price":"40",
            "day":"5",
            "vip":"包邮包送、免押金",
            "yajin":"1000",
            "new":"h_7",
            "img":"iphone11Pro",
        ],[
            "name":"Apple iPhone 12 Pro 移动联通电信 5G手机 双卡双待",
            "price":"65",
            "day":"5",
            "vip":"包邮包送、免押金",
            "yajin":"1500",
            "new":"",
            "img":"iphone11Pro",
        ],[
            "name":"Apple iPhone 11 Pro Max (A2220) 256GB 暗夜绿色 移动联通电信 5G手机 双卡双待",
            "price":"60",
            "day":"10",
            "vip":"包邮包送",
            "yajin":"2000",
            "new":"h_9",
            "img":"iphone11Pro",
        ],[
            "name":"Apple iPhone 14 Pro 256GB 暗夜绿色 移动联通电信 5G手机 双卡双待",
            "price":"100",
            "day":"20",
            "vip":"包邮包送、免押金",
            "yajin":"3000",
            "new":"",
            "img":"iphone11Pro",
        ], [
            "name":"尼康（Nikon）D7500 单反相机 数码相机 （AF-S DX 尼克尔 18-140mm f/3.5-5.6G ED VR 单反镜头）",
            "price":"100",
            "day":"3",
            "vip":"包邮包送、免押金",
            "yajin":"5000",
            "new":"",
            "img":"iphone11Pro",
        ],
        
    ],
    NEW:[
        [
            "name":"Apple iPhone 11 Pro Max (A2220) 256GB 暗夜绿色 移动联通电信 5G手机 双卡双待",
            "price":"100",
            "day":"10",
            "vip":"包邮包送、免押金",
            "yajin":"3000",
            "new":"",
            "img":"iphone11Pro",
        ],
        [
            "name":"Apple iPhone 11 (A2223) 128GB 黑色 移动联通电信5G手机 双卡双待",
            "price":"70",
            "day":"5",
            "vip":"包邮包送、免押金",
            "yajin":"2500",
            "new":"",
            "img":"iphone11",
        ],
        [
            "name":"Apple iphone x 苹果X (A1865) 全网通4G手机 银色 256GB",
            "price":"50",
            "day":"5",
            "vip":"包邮包送、免押金",
            "yajin":"1500",
            "new":"",
            "img":"iphoneX",
        ],
        [
            "name":"Apple iphone x 苹果X (A1865) 全网通4G手机 银色 128GB",
            "price":"50",
            "day":"5",
            "vip":"包邮包送、免押金",
            "yajin":"1200",
            "new":"",
            "img":"iphoneX",
        ],
        [
            "name":"Apple iPhone 14 512G 黑色 移动联通电信5G手机 双卡双待",
            "price":"180",
            "day":"5",
            "vip":"包邮包送、免押金",
            "yajin":"4500",
            "new":"",
            "img":"iphone11",
        ],
        [
            "name":"Apple iPhone 14 黑色 移动联通电信5G手机 8GB+256GB亮黑色全网通5G手机",
            "price":"170",
            "day":"5",
            "vip":"包邮包送、免押金",
            "yajin":"4000",
            "new":"",
            "img":"iphone11",
        ],
        [
            "name":"Apple iPhone 13 黑色 256GB亮黑色全网通5G手机",
            "price":"120",
            "day":"5",
            "vip":"包邮包送、免押金",
            "yajin":"1500",
            "new":"",
            "img":"iphone11Pro",
        ],
        [
            "name":"Apple iPhone 13 Pro Max (A2220) 256GB 暗夜绿色 移动联通电信 5G手机 双卡双待",
            "price":"150",
            "day":"5",
            "vip":"包邮包送、免押金",
            "yajin":"2000",
            "new":"",
            "img":"iphone11Pro",
        ],
    ],
    OLD:[
        [
            "name":"Apple iPhone 11 Pro Max (A2220) 256GB 暗夜绿色 移动联通电信 5G手机 双卡双待",
            "price":"50",
            "day":"10",
            "vip":"包邮包送",
            "yajin":"2000",
            "new":"h_9",
            "img":"iphone11Pro",
        ],
        [
            "name":"Apple iPhone 11 (A2223) 128GB 黑色 移动联通电信5G手机 双卡双待",
            "price":"40",
            "day":"5",
            "vip":"包邮包送、免押金",
            "yajin":"2000",
            "new":"h_8",
            "img":"iphone11",
        ],
        [
            "name":"Apple iphone x 苹果X (A1865) 全网通4G手机 银色 256GB",
            "price":"20",
            "day":"5",
            "vip":"免押金",
            "yajin":"1000",
            "new":"h_5",
            "img":"iphoneX",
        ],
        [
            "name":"小米10 Pro 双模5G 骁龙865 1亿像素8K电影相机 50倍变焦 50W快充 8GB+256GB 珍珠白 拍照智能游戏手机",
            "price":"30",
            "day":"5",
            "vip":"包邮包送、免押金",
            "yajin":"1000",
            "new":"h_7",
            "img":"xiaomi10Pro",
        ],
        [
            "name":"Redmi Note8Pro 6400万全场景四摄 液冷游戏芯 4500mAh NFC 18W快充 6GB+128GB 冰翡翠 游戏手机 小米 红米",
            "price":"40",
            "day":"5",
            "vip":"包邮包送、免押金",
            "yajin":"1300",
            "new":"h_9",
            "img":"RedmiNote8Pro",
        ],
        [
            "name":"华为 HUAWEI P40 Pro 麒麟990 5G SoC芯片 5000万超感知徕卡四摄 50倍数字变焦 8GB+256GB亮黑色全网通5G手机",
            "price":"40",
            "day":"5",
            "vip":"包邮包送、免押金",
            "yajin":"1500",
            "new":"h_9",
            "img":"huaweiP40Pro",
        ],
        [
            "name":"华为 HUAWEI nova 6 5G 105°前置广角双摄 超感光暗拍 麒麟990芯片8GB+128GB亮黑色全网通双卡双待",
            "price":"40",
            "day":"5",
            "vip":"包邮包送、免押金",
            "yajin":"1000",
            "new":"h_8",
            "img":"huaiweinova6",
        ],
        [
            "name":"华为 HUAWEI 畅享10 Plus 超高清全视屏前置悬浮式镜头4800万超广角AI三摄 4GB+128GB天空之境全网通双4G手机",
            "price":"30",
            "day":"5",
            "vip":"免押金",
            "yajin":"900",
            "new":"h_7",
            "img":"huaweishangxiang10",
        ],
    ],
    PINGBAN:[
        [
            "name":"华为HUAWEI MateBook 14 2020款全面屏轻薄性能笔记本电脑 十代酷睿(i7 16G 512G MX250 触控屏 多屏协同)灰",
            "price":"80",
            "day":"20",
            "vip":"包邮包送、免押金",
            "yajin":"3000",
            "new":"",
            "img":"huaweiMate14",
        ],
        [
            "name":"RedmiBook 14 增强版 全金属超轻薄(第十代英特尔酷睿i7-10510U 8G 512G SSD MX250 2G独显 支持手环疾速解锁 Office)游戏 银 笔记本 小米 红米",
            "price":"60",
            "day":"20",
            "vip":"包邮包送、免押金",
            "yajin":"2500",
            "new":"",
            "img":"redmiBook14",
        ],
        
    ],
    SHUMA:[
        [
            "name":"尼康（Nikon）D7500 单反相机 数码相机 （AF-S DX 尼克尔 18-140mm f/3.5-5.6G ED VR 单反镜头）",
            "price":"100",
            "day":"3",
            "vip":"包邮包送、免押金",
            "yajin":"5000",
            "new":"",
            "img":"nikangD7500",
        ],
        [
            "name":"爱百分 i90儿童拍照相机5000W高清数码智能相机小男孩女孩玩具3-12岁",
            "price":"70",
            "day":"3",
            "vip":"包邮包送、免押金",
            "yajin":"1500",
            "new":"",
            "img":"aibaifeni90",
        ],
    ],
    
]

func LocalizedString(_ key:String) -> String {
    return NSLocalizedString(key, comment: "")
}

//自定义字体或系统其他字体
func kNumberFONT(_ R:CGFloat) -> UIFont!{
    return UIFont.init(name: "DIN Alternate", size: pixw(p: R)) ?? MY_SCALE_FONT(pixw(p: R))
}

//普通字体
func MY_SCALE_FONT(_ R:CGFloat) -> UIFont! {
    return UIFont.systemFont(ofSize: pixw(p: R))
}

//默认加粗字体
func MY_SCALE_BoldFont(_ R:CGFloat) -> UIFont! {
    return UIFont.boldSystemFont(ofSize: pixw(p: R))
}

//PingFangSC-Regular
func MY_SCALE_RegularFONT(_ R:CGFloat) -> UIFont! {
    return UIFont(name: "PingFangSC-Light", size: pixw(p: R)) ?? MY_SCALE_FONT(pixw(p: R))
}

func MY_SCALE_HeavyFONT(_ R:CGFloat) -> UIFont! {
    return UIFont(name: "PingFangSC-Semibold", size: pixw(p: R)) ?? MY_SCALE_FONT(pixw(p: R))
}

func MY_SCALE_LightFONT(_ R:CGFloat) -> UIFont! {
    return UIFont(name: "PingFangSC-Light", size: pixw(p: R)) ?? MY_SCALE_FONT(pixw(p: R))
}

func MY_SCALE_UltralightFONT(_ R:CGFloat) -> UIFont! {
    return UIFont(name: "PingFangSC-Ultralight", size: pixw(p: R)) ?? MY_SCALE_FONT(pixw(p: R))
}

func MY_SCALE_ThinFONT(_ R:CGFloat) -> UIFont! {
    return UIFont(name: "PingFangSC-Thin", size: pixw(p: R)) ?? MY_SCALE_FONT(R)
}

func MY_SCALE_MediumFONT(_ R:CGFloat) -> UIFont! {
    return UIFont(name: "PingFangSC-Medium", size: pixw(p: R)) ?? MY_SCALE_FONT(pixw(p: R))
}

func MY_SCALE_SemiboldFONT(_ R:CGFloat) -> UIFont! {
    return UIFont(name: "PingFangSC-Semibold", size: pixw(p: R)) ?? MY_SCALE_FONT(pixw(p: R))
}

//heavy
func KHFONT(_ R:CGFloat) -> UIFont {
    return UIFont.systemFont(ofSize: pixw(p: R), weight: .heavy)
}


//根据当前屏幕宽度得到宽度
func pixw(p:CGFloat) ->CGFloat{
    return (SCREEN_WIDTH/395.0)*p
}

//根据当前屏幕高度得到高度
func pixh(p:CGFloat) ->CGFloat{
    return (SCREEN_HEIGHT/395)*p
}

func RGBA(_ r:CGFloat,_ g:CGFloat,_ b:CGFloat,_ a:CGFloat) ->UIColor{
    return UIColor(red: r / 255, green: g / 255, blue: b / 255, alpha: a)
}

/// 顶部安全区高度
func safeDistanceTop() -> CGFloat {
    let scene = UIApplication.shared.connectedScenes.first
    guard let windowScene = scene as? UIWindowScene else { return 0 }
    guard let window = windowScene.windows.first else { return 0 }
    return window.safeAreaInsets.top
}

/// 底部安全区高度
func safeDistanceBottom() -> CGFloat {
    let scene = UIApplication.shared.connectedScenes.first
    guard let windowScene = scene as? UIWindowScene else { return 0 }
    guard let window = windowScene.windows.first else { return 0 }
    return window.safeAreaInsets.bottom
}

/// 顶部状态栏高度（包括安全区）
 func statusBarHeight() -> CGFloat {
    var statusBarHeight: CGFloat = 0
     let scene = UIApplication.shared.connectedScenes.first
     guard let windowScene = scene as? UIWindowScene else { return 0 }
     guard let statusBarManager = windowScene.statusBarManager else { return 0 }
     statusBarHeight = statusBarManager.statusBarFrame.height
    return statusBarHeight
}

/// 导航栏高度
func navigationBarHeight() -> CGFloat {
    return 44.0
}

/// 状态栏+导航栏的高度
func navigationFullHeight() -> CGFloat {
    return statusBarHeight() + navigationBarHeight()
}

/// 底部导航栏高度
 func tabBarHeight() -> CGFloat {
    return 49.0
}

/// 底部导航栏高度（包括安全区）
 func tabBarFullHeight() -> CGFloat {
    return tabBarHeight() + safeDistanceBottom()
}
